home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Examples / GMExample / GMExampleMain.c < prev   
Encoding:
C/C++ Source or Header  |  1997-06-17  |  2.4 KB  |  122 lines

  1. /*
  2.     C source code created by Interface Editor
  3.     Copyright © 1994-1996 by Simone Tellini
  4.  
  5.     Generator:  C.generator 37.2 (22.2.96)
  6.  
  7.     Copy registered to :  Gian Maria Calzolari - Beta Tester 2
  8.     Serial Number      : #2
  9. */
  10.  
  11. #define INTUI_V36_NAMES_ONLY
  12.  
  13. #include <dos/dos.h>
  14. #include <exec/libraries.h>
  15. #include <clib/exec_protos.h>
  16. #include <clib/dos_protos.h>
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <errno.h>
  22.  
  23. #include "SysHD:Develop/ieditor/EsempiMiei/GMExample.h"
  24. int    main( void );
  25. void   OpenLibs( void );
  26. void   Setup( void );
  27. void   CloseLibs( void );
  28. void   CloseAll( void );
  29. void   PlayTheGame( void );
  30. void   Error( STRPTR, STRPTR );
  31. void   End( ULONG );
  32. int    wbmain( struct WBStartup * );
  33. extern void MySetup( void );
  34.  
  35. BOOL            Ok_to_Run = TRUE;
  36. ULONG           mask = NULL;
  37.  
  38. extern struct Library   *SysBase;
  39. extern struct Library   *DOSBase;
  40. struct WBStartup        *WBMsg = NULL;
  41. struct Library      *RexxSysBase = NULL;
  42.  
  43. #include "IE_Errors.h"
  44.  
  45. int main( void )
  46. {
  47.     OpenLibs();
  48.     Setup();
  49.     MySetup();
  50.     PlayTheGame();
  51.     End( RETURN_OK );
  52. }
  53.  
  54. void End( ULONG RetCode )
  55. {
  56.     CloseAll();
  57.     CloseLibs();
  58.     exit( RetCode );
  59. }
  60.  
  61. void OpenLibs( void )
  62. {
  63.     if (!( RexxSysBase = OpenLibrary( "rexxsyslib.library", 0 )))
  64.     Error( ErrStrings[ OPEN_LIB ], "rexxsyslib.library" );
  65. }
  66.  
  67. void Setup( void )
  68. {
  69.     ULONG       ret;
  70.     if (!( OpenDiskFonts()))
  71.     Error( ErrStrings[ OPEN_FONTS ], NULL );
  72.     if ( ret = SetupScreen())
  73.     Error( ErrStrings[ SETUP_SCR ], ErrStrings[ SETUP_SCR+ret ]);
  74.     if ( ret = OpenMiaFinWindow())
  75.     Error( ErrStrings[ OPEN_WND ], ErrStrings[ OPEN_WND+ret ]);
  76.     SetupRexxPort();
  77. }
  78.  
  79. void CloseAll( void )
  80. {
  81.     CloseMiaFinWindow();
  82.     CloseDownScreen();
  83.     CloseDiskFonts();
  84.     DeleteRexxPort();
  85. }
  86.  
  87. void CloseLibs( void )
  88. {
  89.     if ( RexxSysBase )
  90.     CloseLibrary( RexxSysBase );
  91.  
  92. }
  93.  
  94. void PlayTheGame( void )
  95. {
  96.     ULONG   signals, other = mask;
  97.     ULONG   MiaFin_signal = 1 << MiaFinWnd->UserPort->mp_SigBit;
  98.     ULONG   rexx_signal = NULL;
  99.  
  100.     if ( RexxPort )
  101.     rexx_signal = 1 << RexxPort->mp_SigBit;
  102.  
  103.     mask = mask | SIGBREAKF_CTRL_C | MiaFin_signal | rexx_signal;
  104.  
  105.     while( Ok_to_Run ) {
  106.     signals = Wait( mask );
  107.     if (signals & MiaFin_signal)
  108.         Ok_to_Run = HandleMiaFinIDCMP();
  109.     if (signals & rexx_signal)
  110.         HandleRexxMsg();
  111.     if (signals & SIGBREAKF_CTRL_C)
  112.         Ok_to_Run = FALSE;
  113.     };
  114.  
  115. }
  116.  
  117. int wbmain( struct WBStartup *msg )
  118. {
  119.     WBMsg = msg;
  120.     return( main() );
  121. }
  122.